package com.sc.nft.hna.form;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.sc.nft.config.hna.HnaConfig;
import com.sc.nft.dto.HnaCardBindDTO;
import com.sc.nft.mapstruct.HnaMapStruct;
import lombok.Data;

import java.util.Map;

/**
 * @Author @Version V1.0 @Description @Date 2020-10-19
 */
@Data
public class R009TransForm extends BaseTransForm {

  private static final long serialVersionUID = 1L;

  public static final String[] encryptArr = new String[] {"oriBindCardAgrNo", "userId"};
  public static final String[] verifyArr =
      new String[] {
        "version",
        "tranCode",
        "merOrderId",
        "merId",
        "charset",
        "signType",
        "resultCode",
        "errorCode"
      };
  public static final String[] submitArr =
      new String[] {
        "version",
        "tranCode",
        "merId",
        "merOrderId",
        "submitTime",
        "msgCiphertext",
        "signType",
        "signValue",
        "merAttach",
        "charset"
      };

  private String oriBindCardAgrNo; // 原绑卡协议号
  private String userId; // 用户ID

  public static final String MAIN_URL = "https://ncount.hnapay.com/api/r009.htm";
  public static final String TRAN_CODE = "R009";

  @Override
  public String getEncryptJsonStr() {
    return getJsonStr(this, encryptArr);
  }

  @Override
  public String getVerifyJsonStr() {
    return getJsonStr(this, verifyArr);
  }

  @Override
  public String getSubmitJsonStr() {
    return getJsonStr(this, submitArr);
  }

  public static Map<String, Object> generateParam(String userNo, HnaConfig hnaConfig, String oriBindCardAgrNo) {
    R009TransForm transForm = new R009TransForm();
    transForm.setUserId(userNo);
    transForm.initCommonParams(TRAN_CODE, hnaConfig.getMerId(), IdWorker.getIdStr(), "");
    transForm.setOriBindCardAgrNo(oriBindCardAgrNo);
    return generateParam(transForm, hnaConfig);
  }
}
